﻿HmJS.$Import('ui.calendar.DatePicker');
//HmJS.$Import('core.domready');

HmJS.register('demo.module.ui.calendar.datepicker.legacy', function ($ns) {
	var that = {};

	that.todo = function () {

		var DatePicker = $ns.ui.calendar.DatePicker;

		var debugElmt = document.id('debug');
		var debug = function (txt) {
			debugElmt.set('text', txt);
		};

		// Events and vista skin
		new DatePicker($$('.demo_vista'), {
			pickerClass: 'datepicker_vista',
			onShow: function () {
				debug('onShow');
			},
			onClose: function () {
				debug('onClose');
			},
			onSelect: function () {
				debug('onSelect');
			},
			onNext: function () {
				debug('onNext');
			},
			onPrevious: function () {
				debug('onPrevious');
			}
		});

		// Dashboard skin
		new DatePicker($$('.demo_dashboard'), { pickerClass: 'datepicker_dashboard' });

		// jQuery UI skin
		new DatePicker($$('.demo_jqui'), {
			pickerClass: 'datepicker_jqui',
			positionOffset: { x: 0, y: 5 },
			format: '%d.%m.%Y %H:%M:%S'
		});

		// Attach the datepicker manually
		var dp = new DatePicker();
		document.id('attach').addEvent('click', function (e) {
			e.stop();
			dp.attach('attachByClick');
		});
		document.id('detach').addEvent('click', function (e) {
			e.stop();
			dp.detach('attachByClick');
		});
		document.id('show').addEvent('click', function (e) {
			e.stop();
			dp.show('attachByClick');
		});

		// Min max date
		new DatePicker('minMax', {
			minDate: '03/05/2010',
			maxDate: '04/05/2011'
		});

		// Toggle
		new DatePicker('toggle', {
			toggle: 'toggler',
			timePicker: true
		});

		// Time
		new DatePicker('time', {
			timePicker: true,
			timePickerOnly: true
		});

		// Date and Time
		new DatePicker('dateandtime', {
			timePicker: true
		});

		// Date object as max/minDate
		new DatePicker('date_object_options', {
			minDate: new Date('03/05/2010'),
			maxDate: new Date('04/05/2011')
		});

	};

	return that;
});
